import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TroubleVO, TroubleForm, TroubleQuery } from '@/api/system/trouble/types';

/**
 * 查询隐患列表
 * @param query
 * @returns {*}
 */

export const listTrouble = (query?: TroubleQuery): AxiosPromise<TroubleVO[]> => {
  return request({
    url: '/system/trouble/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询隐患详细
 * @param id
 */
export const getTrouble = (id: string | number): AxiosPromise<TroubleVO> => {
  return request({
    url: '/system/trouble/' + id,
    method: 'get'
  });
};

/**
 * 新增隐患
 * @param data
 */
export const addTrouble = (data: TroubleForm) => {
  return request({
    url: '/system/trouble',
    method: 'post',
    data: data
  });
};

/**
 * 修改隐患
 * @param data
 */
export const updateTrouble = (data: TroubleForm) => {
  return request({
    url: '/system/trouble',
    method: 'put',
    data: data
  });
};

/**
 * 删除隐患
 * @param id
 */
export const delTrouble = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/trouble/' + id,
    method: 'delete'
  });
};
